import os
import zipfile

def do_zip_compress(dirpath):
  output_name = f"{dirpath}.zip"
  parent_name = os.path.dirname(dirpath)
  print("parent_name:", parent_name)
  zip = zipfile.ZipFile(output_name, "w", zipfile.ZIP_DEFLATED)
  for root, dirs, files in os.walk(dirpath):
    for file in files:
      if str(file).startswith("~$"):
        continue
      filepath = os.path.join(root, file)
      print(filepath)
      writepath = os.path.relpath(filepath, parent_name)
      zip.write(filepath, writepath)
  zip.close()

dirpath = r"D:\workbench\ant-python-exercises-100p"
do_zip_compress(dirpath)
